drop sequence eb_user_id;
drop sequence eb_goods_id;
drop sequence eb_category_id;
drop sequence eb_address_id;
drop sequence eb_order_id;
drop sequence eb_orderitem_id;


create sequence eb_user_id;
create sequence eb_category_id;
create sequence eb_goods_id;
create sequence eb_address_id;
create sequence eb_order_id;
create sequence eb_orderitem_id;

drop table eb_orderitem;
drop table eb_order;
drop table eb_address;
drop table eb_user;
drop table eb_goods;
drop table eb_category;
-- 用户表格
create table eb_user(
  userid 		number(7) 		primary key,
  username 	varchar2(30) 	not null unique,
  password 	varchar2(30) 	not null,
  email 		varchar2(30),
  name 		varchar2(20),
  birthday 	DATE,
  address 	varchar2(30)
);
--商品类型表
create table eb_category(
  cateid number(7) primary key,
  cateName varchar2(20) not null
);
--商品表
create table eb_goods(
  goodsId number(7) primary key,
  isbn    varchar2(20) not null,
  name    varchar2(20),
  price   number(10,2),
  discount number(10,2),
  imageUrl varchar2(30),
  info    varchar2(128),
  goods_CateId number(7),
  constraint 	eb_goods_CateId_fk foreign key(goods_CateId)
  references eb_category(cateid)
);
--地址表
create table eb_address(
  addressId number(7) primary key,
  company varchar2(30),
  area varchar2(30),
  zip varchar2(30),
  user_id number(7),
  constraint 	eb_address_user_id_fk foreign key(user_id)
  references eb_user(userid)
);
--订单表
create table eb_order(
  orderId number(7) primary key,
  orderNum number(15),
  createDate DATE,
  user_id number(7),
  address_id number(7)
);
--订单明细表
create table eb_orderitem(
  itemId  number(7) primary key,
  goods_isbn varchar2(30),
  goods_name varchar2(30),
  price number(10,8),
  count number(3),
  goods_imageUrl varchar2(30),
  order_id number(7)
);

insert into eb_user values (eb_user_id.nextval,'admin','123456','1360884472@qq.com','jack',sysdate,'China');

insert into eb_category values (eb_category_id.nextval,'电子产品');
insert into eb_category values (eb_category_id.nextval,'衣服鞋子');
insert into eb_category values (eb_category_id.nextval,'生活用品');

insert into eb_goods values (eb_goods_id.nextval,'ISBN-1001','索尼相机',1223.89,30.00,'1.jpg','用过的都说好',1);
insert into eb_goods values (eb_goods_id.nextval,'ISBN-1002','高跟鞋',223.89,18.00,'b1.jpg','穿过的都说好',2);

